using System;
using System.Collections.Generic;
using System.Text;

namespace PDSClient.Communication
{
    /// <summary>
    /// Listener for communications events that occur on an associated IClientConnection.
    /// </summary>
    public interface IClientConnectionListener
    {
        /// <summary>
        /// Notifies this listener that a transport connection has
        /// been established.
        /// </summary>
        /// <param name="connection">the newly established connection</param>
        void Connected(IClientConnection connection);

        /// <summary>
        /// Notifies this listener that protocol data has arrived from the
        /// server.
        /// </summary>
        /// <param name="message">protocol-specific message data</param>
        void ReceivedMessage(byte[] message);

        /// <summary>
        /// Notifies this listener that a new session has successfully logged in.
        /// </summary>
        /// <param name="message">protocol-specific session-start data</param>
        /// <returns>the listener for events on the new ServerSession</returns>
        IServerSessionListener SessionStarted(byte[] message);

        /// <summary>
        /// Notifies this listener that its associated server connection is in
        /// the process of reconnecting with the server.
        /// <p>
        /// If a connection can be re-established with the server in a
        /// timely manner, this listener's Reconnected
        /// method will be invoked.  Otherwise, if a connection cannot be
        /// re-established, this listener's Disconnected
        /// method will be invoked with false indicating that
        /// the associated session has been disconnected from the server
        /// and the client must log in again.
        /// </summary>
        /// <param name="message">protocol-specific reconnection data</param>
        void Reconnecting(byte[] message);

        /// <summary>
        /// Notifies this listener that a reconnection effort was successful.
        /// </summary>
        /// <param name="message">protocol-specific reconnection data</param>
        void Reconnected(byte[] message);

        /// <summary>
        /// Notifies this listener that the associated server connection is
        /// disconnected.
        /// <p>
        /// If graceful is true, the disconnection was due to
        /// the associated client gracefully logging out; otherwise, the
        /// disconnection was due to other circumstances, such as forced
        /// disconnection or network failure.
        /// </summary>
        /// <param name="graceful">true if disconnection was part of graceful logout, otherwise false</param>
        /// <param name="message">protocol-specific reconnection data</param>
        void Disconnected(Boolean graceful, byte[] message);
    }
}
